<template>
  <div class="fdsBusinessStartRuleset-remove-component">
    <el-dialog
      v-if="modelValue.visible"
      v-model="modelValue.visible"
      title="提示"
      width="400px"
    >
      <span
        >当前操作将{{
          modelValue.form.enabled == "1" ? "启用" : "禁用"
        }}该打烊规则,是否继续？</span
      >
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="cancel">取消</el-button>
          <el-button type="danger" @click="ensure"> 确定 </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
//提示弹框。
import { ElMessage } from "element-plus";
//请求对应的删除接口。
// import { updateFdsBusinessStartRuleset } from "@/api/fds-business-start-ruleset.api";
import {
  getFdsBusinessClosingRulesetPagination,
  getFdsBusinessClosingRulesetAllList,
  updateFdsBusinessClosingRuleset,
} from "@/api/fds-business-closing-ruleset.api";

//获取从父组件传来的数据。
const props = defineProps(["modelValue"]);

const ensure = () => {
  let id = props.modelValue.form.id;
  let formData = {
    id,
    enabled: props.modelValue.form.enabled,
  };
  updateFdsBusinessClosingRuleset(formData)
    .then((res) => {
      cancel();
      ElMessage({
        message: "操作成功",
        type: "success",
      });

      if (props.modelValue.refreshDataList) {
        props.modelValue.refreshDataList();
      }
    })
    .catch((err) => {
      cancel();
      ElMessage({
        message: err.msg || err,
        type: "error",
      });
    });
};

const cancel = () => {
  props.modelValue.visible = false;
};
</script>
<style lang="scss" scoped></style>
